package com.hc.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hc.entity.QcEquipment;
import com.hc.model.QcEquipmentFind;
import com.hc.service.QcEquipmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author LiuZhiHao
 * @date 2019/8/28 9:36
 * 描述:
 **/
@RestController
@RequestMapping("/qcequipment")
@Api(description = "设备信息管理")
public class QcEquipmentController {

    @Autowired
    private QcEquipmentService qcEquipmentService;


    @PostMapping("")
    @ApiOperation("新增/修改设备")
    public void saveEquipment(@RequestBody QcEquipment qcEquipment){
        qcEquipmentService.saveEquipment(qcEquipment);
    }


    @PostMapping("/page")
    @ApiOperation("根据设备分类id获取设备不传查所有")
    public Page<QcEquipment> getallqcequitmentByCid(@RequestBody QcEquipmentFind qcEquipmentFind){
        return qcEquipmentService.getallqcequitmentByCid(qcEquipmentFind);
    }

    @GetMapping("/getAllDeviceNameForClassifyId")
    @ApiOperation("获取对应设备的所有设备名称")
    public List<QcEquipment> getAllDeviceNameForClassifyId(String classifyId){
        return qcEquipmentService.getAllDeviceNameForClassifyId(classifyId);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除设备")
    public void deleteEquipment(@PathVariable(value = "id") int id){
        qcEquipmentService.deleteEquipment(id);
    }

    @GetMapping("/scanidentify/{scId}")
    @ApiOperation("根据设备标识码获取设备信息")
    public QcEquipment getQcEquipmentByScId(@PathVariable(value = "scId") String scId){
        return qcEquipmentService.getQcEquipmentByScId(scId);
    }


    @GetMapping("/list")
    @ApiOperation("获取所有设备可用设备信息")
    public List<QcEquipment> listEq(){
        return qcEquipmentService.listEq();
    }
}
